package com.edu.user.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.edu.user.domain.po.Appointment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AppointmentMapper extends BaseMapper<Appointment> {

    default List<Appointment> selectListByPatientId(Long patientId) {
        QueryWrapper<Appointment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("patient_id", patientId);
        return selectList(queryWrapper);
    }
    default List<Appointment> selectListByDoctorId(Long doctorId) {
        QueryWrapper<Appointment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("doctor_id", doctorId);
        return selectList(queryWrapper);
    }
    @Select("SELECT COUNT(*) FROM appointments WHERE patient_id = #{patientId} AND schedules_id = #{schedulesId}")
    int countByPatientIdAndSchedulesId(@Param("patientId") Long patientId, @Param("schedulesId") Long schedulesId);

}
